import $ from "@/utils/requset";
// 有参数的get请求
// 商品列表数据
const getGoodsApi = (pagenum, pagesize) => $.getAxios('/goods', {
    pagenum,
    pagesize
});
// 删除商品
const deleteGoddsApi = (id) => $.deleteAxios(`/goods/${id}`);
// 请求商品分类
const getCategoryApi = () => $.getAxios('/categories');
// 添加商品
const setGoodsApi = (obj) => $.postAxios('/goods', obj);
// 参数列表
const getAttributesApi = (id) => $.getAxios(`/categories/${id}/attributes`, {
    sel: 'many'
});
// 商品属性
const getOnlyApi = (id) => $.getAxios(`/categories/${id}/attributes`, {
    sel: 'only'
});
// 修改分类参数属性
const editAttr = (id, attrId, obj) => $.putAxios(`/categories/${id}/attributes/${attrId}`, obj);
// 删除分类参数
const removeAttr = (id, attrId) => $.deleteAxios(`/categories/${id}/attributes/${attrId}`);
// 搜索商品
const searchGoods = (name, pagenum, pagesize) => $.getAxios('/goods', {
    query: name,
    pagenum,
    pagesize
});
//获取分类
const getCateApi = (type, pagenum, pagesize) => $.getAxios('/categories', {
    type,
    pagenum,
    pagesize
})
//编辑分类
const editCateApi = (id, cat_name) => $.putAxios(`/categories/${id}`, {
    cat_name
})
//删除分类
const deleteCateApi = (id) => $.deleteAxios(`/categories/${id}`);
//添加商品分类
const addCateApi = (cat_level, cat_name, cat_pid) => $.postAxios(`/categories`, {
    cat_level,
    cat_name,
    cat_pid

});
export default {
    getGoodsApi,
    deleteGoddsApi,
    getCategoryApi,
    setGoodsApi,
    getAttributesApi,
    getOnlyApi,
    editAttr,
    removeAttr,
    searchGoods,
    getCateApi,
    editCateApi,
    deleteCateApi,
    addCateApi
}